Skip to content

[Connectors] Implement health check for connectors - #3811

Merged
mlodic merged 12 commits into
gsoc-2026/connectorsfrom
gsoc-2026/feat-connectors-health-check
Jun 30, 2026
Merged

[Connectors] Implement health check for connectors#3811
mlodic merged 12 commits into
gsoc-2026/connectorsfrom
gsoc-2026/feat-connectors-health-check

Conversation

@sanjib2006

@sanjib2006 sanjib2006 commented Jun 26, 2026

Copy link
Copy Markdown
Member

Closes #928

Description

Health Check methods implemented for connectors

  • YETI - successful auth token means health check passes
  • Slack - slack sdk has an auth_test(), calling it validates the token and also identity info
  • OpenCTI - called native health_check() method of pycti
  • MISP - calling the misp_instance_version which connects the server instance and returns the server instance version and related info
  • Tests (8 tests - 2 per connector): One health check success and one health check failure (containing multiple cases as subtests) per connector

Type of change

  • New feature (non-breaking change which adds functionality).

Checklist

  • I have read and understood the rules about how to Contribute to this project
  • The pull request is for the branch gsoc-2026/connectors
  • I have added tests for the feature/bug I solved (see tests folder). All the tests (new and old ones) gave 0 errors.

@sanjib2006 sanjib2006 linked an issue Jun 26, 2026 that may be closed by this pull request
Comment on lines +52 to +60
auth_resp = requests.post(
url=auth_url,
headers=auth_headers,
verify=verify_ssl,
timeout=10,
)
auth_resp.raise_for_status()
access_token = auth_resp.json().get("access_token")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For yeti:
I am checking a post request to get the access token, if the server responsds a valid token then the health check passes.

Check this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshots of the logs of various variations for YETI:

failed due to invalid url
image

invalid api key
image

video

2026-06-29.22-16-44.mp4

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests(including two health check tests) are passing
image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here ,a comment in the code about your decision of using the access token and why, just like you did in this github comment

Comment on lines +58 to +61
try:
client = slack_sdk.WebClient(token=token)
client.auth_test()
return True

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slack:

  • this tests if the token is valid by doing an authentication test + returns identity info (discarded that info)

we had two more params (channel and slack_username) channel just wants a valid channel name on the slack channel and slack_username could be anything (this is just added to the info we send to slack). So I have not added these two to the test + auth_test() requires only the token

Official docs here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logs:

invalid api
image

missing token
image

video:

2026-06-29.22-38-04.mp4

tests:
image

I have added only the health check tests for now. I will add other tests for slack later.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, add a comment please

Comment on lines +216 to +219
try:
client = pycti.OpenCTIApiClient(url, token, ssl_verify=ssl_verify, proxies=proxies)
resp = client.health_check()
return resp

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenCTI:

  • pycti does have a health_check(), so just created a client and called that method

docs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logs:

missing url
image

invalid api_key
image

video:

2026-06-29.22-59-30.mp4

tests:
image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for showing the demo. Very helpful. Is there any chance to modify the toast shown to the user to explain which is the issue? Otherwise it would be difficult for an user to understand the cause. Admins have logs but a classic user can't see them.
That would be a very good addition for all the cases

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here, please add a comment and a link about what you explained regarding the health check

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for showing the demo. Very helpful. Is there any chance to modify the toast shown to the user to explain which is the issue? Otherwise it would be difficult for an user to understand the cause. Admins have logs but a classic user can't see them. That would be a very good addition for all the cases

yaa I was also thinking about this while doing it that it would better if the cause was visible in the ui itself, I will check and let you know

Comment on lines +156 to +170
try:
misp = pymisp.PyMISP(
url=url,
key=key,
ssl=ssl_param,
debug=False,
timeout=5,
)

misp.misp_instance_version
return True

except Exception as e:
logger.info(f"MISP health check failed: {e}")
return False

@sanjib2006 sanjib2006 Jun 29, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MISP:

  • misp_instance_version returns the server's (MISP instance) version, so it does make a request to the server and also checks the validity of the api key

docs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the information about misp_instance_version as a comment? Otherwise that info would be lost for future maintainers.

@sanjib2006
sanjib2006 marked this pull request as ready for review June 29, 2026 18:40
@sanjib2006

Copy link
Copy Markdown
Member Author

Hi @mlodic please have a look at this.

Email sender/abuse submitter do not use config url/api key or remote instances so I have not done anything for them.

If changes are required then do let me know.

Thanks!

@mlodic mlodic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good work, added some comments

Comment on lines +216 to +219
try:
client = pycti.OpenCTIApiClient(url, token, ssl_verify=ssl_verify, proxies=proxies)
resp = client.health_check()
return resp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for showing the demo. Very helpful. Is there any chance to modify the toast shown to the user to explain which is the issue? Otherwise it would be difficult for an user to understand the cause. Admins have logs but a classic user can't see them.
That would be a very good addition for all the cases

Comment on lines +156 to +170
try:
misp = pymisp.PyMISP(
url=url,
key=key,
ssl=ssl_param,
debug=False,
timeout=5,
)

misp.misp_instance_version
return True

except Exception as e:
logger.info(f"MISP health check failed: {e}")
return False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the information about misp_instance_version as a comment? Otherwise that info would be lost for future maintainers.

Comment on lines +216 to +219
try:
client = pycti.OpenCTIApiClient(url, token, ssl_verify=ssl_verify, proxies=proxies)
resp = client.health_check()
return resp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here, please add a comment and a link about what you explained regarding the health check

Comment on lines +58 to +61
try:
client = slack_sdk.WebClient(token=token)
client.auth_test()
return True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, add a comment please

Comment on lines +52 to +60
auth_resp = requests.post(
url=auth_url,
headers=auth_headers,
verify=verify_ssl,
timeout=10,
)
auth_resp.raise_for_status()
access_token = auth_resp.json().get("access_token")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here ,a comment in the code about your decision of using the access token and why, just like you did in this github comment

@sanjib2006

Copy link
Copy Markdown
Member Author

I will add the comments as you said and then this PR can be closed.

For the failure messages, we have to do slight changes in the backend, health_check methods and the frontend files.
Those are designed to return only status(true/false). We can update it to a message with the status.
I plan to do this by creating a new issue after completing this PR.

Thanks for the review 🙌

@mlodic

mlodic commented Jun 30, 2026

Copy link
Copy Markdown
Member

thanks to you for the work, looking forward the next improvements.

@sanjib2006

Copy link
Copy Markdown
Member Author

Hey @mlodic, I have added the comments.
Should I add the reference docs/url in the comments also?

@mlodic

mlodic commented Jun 30, 2026

Copy link
Copy Markdown
Member

yep if possible yes so we can track possible changes in the future

@sanjib2006

Copy link
Copy Markdown
Member Author

@mlodic Done 🔥
I have added the official reference links as comments.

@mlodic
mlodic merged commit 68694fb into gsoc-2026/connectors Jun 30, 2026
3 checks passed
@sanjib2006
sanjib2006 deleted the gsoc-2026/feat-connectors-health-check branch July 1, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make Connectors Health Checks more reliable

2 participants